package com.lagou.ipersistence.session;

import com.lagou.ipersistence.builder.xml.XMLConfigBuilder;
import com.lagou.ipersistence.session.defaults.DefaultSqlSessionFactory;
import org.dom4j.DocumentException;

import java.beans.PropertyVetoException;
import java.io.InputStream;

/**
 * @author Yan Jiahong
 * Created on 2020/11/7
 */
public class SqlSessionFactoryBuilder {
    public SqlSessionFactory build(InputStream in) throws PropertyVetoException, DocumentException {
        //
        XMLConfigBuilder xmlConfigBuilder = new XMLConfigBuilder(in);
        Configuration configuration = xmlConfigBuilder.parse();

        // 创建SqlSessionFactory对象
        return new DefaultSqlSessionFactory(configuration);
    }
}
